package disign;

import java.time.LocalDateTime;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author zheng
 */
public class TestDemo4 {

    public synchronized void method(){
        System.out.println("普通方法执行时间：" + LocalDateTime.now());
        try {
            Thread.sleep(5000);
        }catch (Exception e){
            e.getMessage();
        }
    }

    public synchronized static void method2(){
        System.out.println("2静态方法执行时间：" + LocalDateTime.now());
        try {
            Thread.sleep(5000);
        }catch (Exception e){
            e.getMessage();
        }
    }

    public static void main(String[] args) throws Exception{
        ExecutorService es = Executors.newFixedThreadPool(10);
        es.execute(() ->{
            TestDemo4.method2();
            TestDemo4.method2();
            TestDemo4 testDemo4 = new TestDemo4();
            TestDemo4 testDemo5 = new TestDemo4();

            testDemo4.method();
            testDemo5.method();
        });
    }
}
